Shader "Z Prepass/transparent"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        // _Glossiness ("Smoothness", Range(0,1)) = 0.5
        // _Metallic ("Metallic", Range(0,1)) = 0.0
        _Alpha("Alpha",Range(0,1)) = 1
    }
    SubShader
    {
        // Tags { "RenderType"="Transparent" "Queue" = "Transparent"}
        // Blend SrcAlpha One

        Pass
        {
            ZWrite on
            Cull off
            ColorMask 0
        }
        Pass
        {
             Cull front
            Tags { "RenderType"="Transparent" }//"Queue" = "Transparent"}
            Blend SrcAlpha OneMinusSrcAlpha
            ZWrite off
            ZTest off //Equal

            CGPROGRAM
            #include "UnityCG.cginc"
            #pragma vertex vert
            #pragma fragment frag

              struct appdata
            {
                float4 pos : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 pos : SV_POSITION;
            };

            
            sampler2D _MainTex;
            float4 _MainTex_ST;
            half _Alpha;

             v2f vert (appdata v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.pos);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);

                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 col = tex2D(_MainTex, i.uv);
                
                col.a = _Alpha;
                return col;
            }
            ENDCG
        }
        Pass
        {
            Cull back
            Tags { "RenderType"="Transparent" "Queue" = "Transparent"}
            // Blend SrcAlpha One
            Blend SrcAlpha OneMinusSrcAlpha
            ZWrite off
            ZTest off //Equal

            CGPROGRAM
            #include "UnityCG.cginc"
            #pragma vertex vert
            #pragma fragment frag

              struct appdata
            {
                float4 pos : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 pos : SV_POSITION;
            };

            
            sampler2D _MainTex;
            float4 _MainTex_ST;
            half _Alpha;

             v2f vert (appdata v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.pos);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);

                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 col = tex2D(_MainTex, i.uv);
                
                col.a = _Alpha;
                return col;
            }
            ENDCG
        }
    }
    FallBack "Diffuse"
}
